package com.ellecity06.debugtools.db.dao

import androidx.room.*
import com.ellecity06.debugtools.db.entity.RequestEntity


/**
 * @author ellecity06
 * @time 2023/4/19 15:50
 * @des
 */
@Dao
interface RequestDao {

    @Query("SELECT * FROM RequestEntity ORDER BY id DESC LIMIT :limit OFFSET :offset")
    suspend fun getRequestList(limit: Int, offset: Int): List<RequestEntity>

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    fun insert(item: RequestEntity): Long

    @Delete
    fun delete(item: RequestEntity)

    @Query("delete from RequestEntity where id =:id")
    suspend fun deleteById(id: Int)

    //根据id查找
    @Query("SELECT * FROM RequestEntity WHERE id LIKE :id")
    suspend fun findById(id: Int): RequestEntity?

    @Query("DELETE FROM RequestEntity")
    suspend fun deleteAll()
}